package main

import "fmt"

// 二维数组
func main() {
	//multiArray01()
	//multiArray02()
	multiArray03()
	multiArray04()
}

func multiArray01() {
	var arr [4][6]int
	arr[1][2] = 1
	arr[2][1] = 2
	arr[2][3] = 3
	for _, as := range arr {
		fmt.Println(as)
	}
}

func multiArray02() {
	var arr [4][6]int = [4][6]int{{0, 0, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 0}, {0, 2, 0, 3, 0, 0}, {0, 0, 0, 0, 0, 0}}
	fmt.Println(arr)
}

func multiArray03() {
	var arr [4][6]int = [4][6]int{
		{11, 12, 13, 14, 15, 16},
		{21, 22, 23, 24, 25, 26},
		{31, 32, 33, 34, 35, 36},
		{41, 42, 43, 44, 45, 46}}
	for i := 0; i < len(arr); i++ {
		for j := 0; j < len(arr[i]); j++ {
			fmt.Printf("%d ", arr[i][j])
		}
		fmt.Println()
	}
	fmt.Println("-----------------------------")
	for _, i := range arr {
		for _, j := range i {
			fmt.Printf("%d ", j)
		}
		fmt.Println()
	}
}

func multiArray04() {
	var arr [4][6]int = [4][6]int{
		{11, 12, 13, 14, 15, 16},
		{21, 22, 23, 24, 25, 26},
		{31, 32, 33, 34, 35, 36},
		{41, 42, 43, 44, 45, 46}}

	var toto int
	for i, v1 := range arr {
		var total int
		for _, v2 := range v1 {
			total += v2
		}
		fmt.Printf("班级=%d,avg=%.2f", i+1, float64(total)/float64(len(v1)))
		toto += total
	}
}
